#include <assert.h>
#include <memory>
#include <mgapiall.h>

#include "animation_player.h"
#include "animation_player_view.h"
#include "animation_player_controller.h"

using namespace std;
using namespace std::tr1;
using namespace tl;

namespace tl
{
mgstatus StartAnimationPlayer (mgplugintool pluginTool, void* userData, void* callData)
{
   mgeditorcallbackrec* cbData = static_cast<mgeditorcallbackrec*>(callData);
	mgresource resource = static_cast<mgresource>(userData);

   if (cbData && cbData->toolActivation && resource)
   {
      mgrec* db = mgGetActivationDb (cbData->toolActivation);
      assert(db);

      animation_player* pPlayer = new animation_player (db);
      shared_ptr<animation_player> spPlayer (pPlayer);
      animation_player_view* pView = new animation_player_view (spPlayer, resource);
      pView->RegisterCreateDialog (pluginTool);

		cbData->dialogRequired = MG_TRUE;
		cbData->toolData = pView;
   }

   return MSTAT_OK;
}
} // end namespace tl